package com.siwei.mes.controller.laboratory;

import com.siwei.mes.common.annotation.AnonymousAccess;
import com.siwei.mes.common.result.ApiResult;
import com.siwei.mes.common.result.Json;
import com.siwei.mes.entity.materials.MaterialsSpecConfig;
import com.siwei.mes.service.system.InitializationService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 同步协会软件相关原材料信息
 *
 * @Description: 同步协会软件相关原材料信息
 * @Version: 1.0
 * @author: mlchen
 * @date: 2024/6/24 00:28
 */
@RestController
@RequestMapping("testSyncLaboratoryMaterials")
public class SyncLaboratoryMaterialsController {
    @Resource
    private InitializationService initializationService;

    /**
     * 同步原材料信息
     * 对应协会的item_item表中的itemId
     * 1-水泥   1101
     * 2-粉煤灰 1117
     * 3-矿渣粉 1124
     * 4-粗骨料 1102
     * 5-细骨料 1103,1203
     * 6-外加剂 1116
     * 7-混凝土 1112,1108,1110,1109
     *
     * @param itemId 多个用逗号隔开
     * @param type   1-水泥 2-粉煤灰 3-矿渣粉 4-粗骨料 5-细骨料 6-外加剂 7-混凝土
     * @return
     */
    @AnonymousAccess
    @GetMapping("syncMaterialsInfo")
    public Json syncMaterialsInfo(@RequestParam("itemId") String itemId, @RequestParam("type") Integer type) {
        List<MaterialsSpecConfig> list = initializationService.initMaterials(itemId, type);
        return Json.succ().data(ApiResult.addList(list));
    }

}
